extern "C" {
    fn strchr(_: *const i8, _: i32) -> *mut i8;
    fn strcspn(_: *const i8, _: *const i8) -> u64;
    fn strspn(_: *const i8, _: *const i8) -> u64;
    fn strlen(_: *const i8) -> u64;
    fn strcasecmp(_: *const i8, _: *const i8) -> i32;
    fn strncasecmp(_: *const i8, _: *const i8, _: u64) -> i32;
    fn xsnprintf(_: *mut i8, _: size_t, _: *const i8, _: ...) -> i32;
}
pub type __u_int = u32;
pub type u_int = __u_int;
pub type size_t = u64;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed {
    pub name: *const i8,
    pub attr: i32,
}
#[no_mangle]
pub extern "C" fn attributes_tostring(mut attr: i32) -> *const i8 {
    static mut buf: [i8; 512] = [0; 512];
    let mut len: size_t = 0;
    if attr == 0 as i32 {
        return b"none\0" as *const u8 as *const i8;
    }
    len = (unsafe {
        xsnprintf(
            buf.as_mut_ptr(),
            ::core::mem::size_of::<[i8; 512]>() as u64,
            b"%s%s%s%s%s%s%s%s%s%s%s%s%s%s\0" as *const u8 as *const i8,
            if attr & 0x80 as i32 != 0 {
                b"acs,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x1 as i32 != 0 {
                b"bright,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x2 as i32 != 0 {
                b"dim,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x4 as i32 != 0 {
                b"underscore,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x8 as i32 != 0 {
                b"blink,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x10 as i32 != 0 {
                b"reverse,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x20 as i32 != 0 {
                b"hidden,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x40 as i32 != 0 {
                b"italics,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x100 as i32 != 0 {
                b"strikethrough,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x200 as i32 != 0 {
                b"double-underscore,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x400 as i32 != 0 {
                b"curly-underscore,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x800 as i32 != 0 {
                b"dotted-underscore,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x1000 as i32 != 0 {
                b"dashed-underscore,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
            if attr & 0x2000 as i32 != 0 {
                b"overline,\0" as *const u8 as *const i8
            } else {
                b"\0" as *const u8 as *const i8
            },
        )
    }) as size_t;
    if len > 0 as i32 as u64 {
        (unsafe { buf[len.wrapping_sub(1 as i32 as u64) as usize] = '\0' as i32 as i8 });
    }
    return unsafe { buf.as_mut_ptr() };
}
#[no_mangle]
pub extern "C" fn attributes_fromstring(mut str: *const i8) -> i32 {
    let delimiters: [i8; 4] = *(unsafe { ::core::mem::transmute::<&[u8; 4], &[i8; 4]>(b" ,|\0") });
    let mut attr: i32 = 0;
    let mut end: size_t = 0;
    let mut i: u_int = 0;
    let mut table: [C2RustUnnamed; 15] = [
        {
            let mut init = C2RustUnnamed {
                name: b"acs\0" as *const u8 as *const i8,
                attr: 0x80 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"bright\0" as *const u8 as *const i8,
                attr: 0x1 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"bold\0" as *const u8 as *const i8,
                attr: 0x1 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"dim\0" as *const u8 as *const i8,
                attr: 0x2 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"underscore\0" as *const u8 as *const i8,
                attr: 0x4 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"blink\0" as *const u8 as *const i8,
                attr: 0x8 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"reverse\0" as *const u8 as *const i8,
                attr: 0x10 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"hidden\0" as *const u8 as *const i8,
                attr: 0x20 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"italics\0" as *const u8 as *const i8,
                attr: 0x40 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"strikethrough\0" as *const u8 as *const i8,
                attr: 0x100 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"double-underscore\0" as *const u8 as *const i8,
                attr: 0x200 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"curly-underscore\0" as *const u8 as *const i8,
                attr: 0x400 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"dotted-underscore\0" as *const u8 as *const i8,
                attr: 0x800 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"dashed-underscore\0" as *const u8 as *const i8,
                attr: 0x1000 as i32,
            };
            init
        },
        {
            let mut init = C2RustUnnamed {
                name: b"overline\0" as *const u8 as *const i8,
                attr: 0x2000 as i32,
            };
            init
        },
    ];
    if (unsafe { *str }) as i32 == '\0' as i32
        || (unsafe { strcspn(str, delimiters.as_ptr()) }) == 0 as i32 as u64
    {
        return -(1 as i32);
    }
    if !(unsafe {
        strchr(
            delimiters.as_ptr(),
            *str.offset((strlen(str)).wrapping_sub(1 as i32 as u64) as isize) as i32,
        )
    })
    .is_null()
    {
        return -(1 as i32);
    }
    if (unsafe { strcasecmp(str, b"default\0" as *const u8 as *const i8) }) == 0 as i32
        || (unsafe { strcasecmp(str, b"none\0" as *const u8 as *const i8) }) == 0 as i32
    {
        return 0 as i32;
    }
    attr = 0 as i32;
    loop {
        end = unsafe { strcspn(str, delimiters.as_ptr()) };
        i = 0 as i32 as u_int;
        while (i as u64)
            < (::core::mem::size_of::<[C2RustUnnamed; 15]>() as u64)
                .wrapping_div(::core::mem::size_of::<C2RustUnnamed>() as u64)
        {
            if end == (unsafe { strlen(table[i as usize].name) }) {
                if (unsafe { strncasecmp(str, table[i as usize].name, end) }) == 0 as i32 {
                    attr |= table[i as usize].attr;
                    break;
                }
            }
            i = i.wrapping_add(1);
        }
        if i as u64
            == (::core::mem::size_of::<[C2RustUnnamed; 15]>() as u64)
                .wrapping_div(::core::mem::size_of::<C2RustUnnamed>() as u64)
        {
            return -(1 as i32);
        }
        str = unsafe {
            str.offset(
                end.wrapping_add(strspn(str.offset(end as isize), delimiters.as_ptr())) as isize,
            )
        };
        if (unsafe { *str }) as i32 == '\0' as i32 {
            break;
        }
    }
    return attr;
}
